home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 11 / AMUG BBS in a Box Volume XI (April 1994) (MacWizards).iso / Files / Prog / T / ToolsPlus 2.1.sit / Tools Plus 2.1 ƒ / Tools Plus 2.1 (C & Pascal) / User Manual / 07-Scroll Bars < prev    next >
Encoding:
Text File  |  1993-10-24  |  15.4 KB  |  248 lines  |  [TEXT/ttxt]

  1. 7  Scroll Bars
  2. ``````````````
  3.  
  4.   Tools Plus supports the use of scroll bars on any window created by the WindowOpen procedure.  Scroll bars are created on the current window by the NewScrollBar procedure.  Each scroll bar is referenced by a unique scroll bar number, that can be from 1 to 255.  This number is specified when the scroll bar is created, and refers to the specific scroll bar until that scroll bar is deleted.  Note that the scroll bar number is related to its associated window.  This means that two different windows can each have a scroll bar numbered “1” without interfering with each other.  Whenever a scroll bar is used by the user, the PollSystem function reports the scroll bar number, the part (see below) that was used, and its window number.
  5.  
  6.   Scroll bars can be either horizontal or vertical, and are made up of five distinct parts:
  7.    [1] up arrow (arrow pointing up on vertical scroll bars, or left on
  8.        horizontal scroll bars)
  9.    [2] down arrow (arrow pointing down on vertical scroll bars, or right
  10.        on horizontal scroll bars)
  11.    [3] thumb (movable tab situated between the up arrow and down arrow)
  12.    [4] “page up” region (the region between the up arrow and the thumb)
  13.    [5] “page down” region  (the region between the down arrow and the
  14.        thumb)
  15.  
  16.   A scroll bar’s minimum and maximum settings can be obtained by the GetScrollBarMin and GetScrollBarMax functions.  The current value can be obtained by the GetScrollBarVal function.  Conversely, these values can be set by using the SetScrollBarMin, SetScrollBarMax, and SetScrollBarVal procedures.
  17.  
  18.   When a scroll bar is no longer required, it is deleted by the DeleteScrollBar procedure, which releases the memory used by the scroll bar.  This is done automatically if a window is closed.
  19.  
  20.  
  21.  
  22.  
  23.  
  24. Scroll Bar States
  25. `````````````````
  26.   A scroll is enabled or disabled by the EnableScrollBar procedure.  When a window is inactive, all the associated scroll bars are automatically hidden (only the outline is displayed) and cannot be selected.  When the window is activated, the scroll bars return to their normal status as set by your application.
  27.  
  28.  
  29.  
  30.  
  31.  
  32. Handling Scroll Bars
  33. ````````````````````
  34.   Your application specifies if a scroll bar is enabled or disabled.  When a window in inactive, Tools Plus disables all scroll bars.  When the window is activated again, all the scroll bars regain their correct status as specified by your application.  If a window contains a scroll bar along its right side and/or bottom (such as on word processing documents and spreadsheets), these scroll bars are automatically sized and moved if the user drags the window’s “size box” (providing that the window has a “size box”) or clicks the “zoom box.”.
  35.  
  36.   The PollSystem function is used to constantly inquire about any events that have occurred, including scroll bar interaction.  If any part of a scroll bar is selected, it will be reported by PollSystem.  When the user moves the scroll bar’s thumb, GetScrollBarVal should be called to obtain the scroll bar’s new value.  Simply moving the thumb, then leaving it in the same position does not generate an event.  If the user clicks and holds the up arrow, “page up” region, down arrow, or “page down” region, PollSystem reports an event for this part of the scroll bar each time PollSystem is called.
  37.  
  38. Warning: If you have obtained a handle to a scroll bar, do not change
  39.          any of the fields in the scroll bar’s record.
  40.  
  41. ------------------------------------------------------------------------
  42.  
  43. NewScrollBar
  44. ````````````
  45. Create a new scroll bar.
  46.  
  47.    pascal void NewScrollBar (int ScrollBar, int left, int top,
  48.                  int right, int bottom, Boolean EnabledFlag,
  49.                  int minimum, int value, int maximum);
  50.  
  51.    procedure NewScrollBar(ScrollBar, left, top, right, bottom: INTEGER;
  52.                  EnabledFlag: BOOLEAN;
  53.                  minimum, value, maximum: INTEGER);
  54.  
  55.   ScrollBar specifies the scroll bar number (from 1 to 255) that will be created in the current window.  Once a scroll bar is created, it will be referenced by this scroll bar number.  If a scroll bar has been previously created in the current window using the same number, it will be replaced with a new scroll bar as specified by the parameters in the NewScrollBar procedure.  If the current window doesn’t belong to your application, or if no windows are open, NewScrollBar does nothing.
  56.  
  57.   Left, top, right, and bottom define a rectangle in local co-ordinates that determines the scroll bar’s size and location in the window.  These parameters can be seen as two corners; the upper left-hand corner (left,top) and the bottom right-hand corner (right,bottom).  A scroll bar will be vertical or horizontal depending on whether the height or width of the rectangle is greatest.  Scroll bars should be exactly 16 pixels wide, so there should be a 16 pixel difference between the scroll bar’s top and bottom, or left and right side.  If there isn’t, the scroll bar will be scaled to fit into the rectangle and will not look as attractive.  Also, the scroll bar must be at least 40 pixels long in order to contain the up arrow, down arrow, and thumb.
  58.  
  59.   For windows with a ProcID of documentProc (i.e. with a “size” box) two special scroll bars may be created; one along the right side of a window and/or one along the bottom.  These scroll bars are special because they are automatically sized and moved if the window’s size is changed.  Here are some useful measurements for these specialized scroll bars:
  60.  
  61. Right scroll bar  (left,top)  To place the top of the scroll bar exactly
  62.                               below the window’s title bar, give left
  63.                               the value of the window’s width - 15, and
  64.                               top the value of -1.  (The window’s width
  65.                               and height can be obtained from the
  66.                               WindowStatus procedure.)
  67.  
  68.               (right,bottom)  To place the bottom of the scroll bar
  69.                               exactly at the upper edge of the “size
  70.                               box”, give right the value of the window’s
  71.                               width + 1, and bottom the value of the
  72.                               window’s height - 14.  If these exact
  73.                               dimensions are not used, the scroll bar
  74.                               will not be sized or moved when the
  75.                               window’s size is changed.
  76.  
  77. Bottom scroll bar (left,top)  To place the left side of the scroll bar
  78.                               exactly at the window’s left edge, give
  79.                               left the value of - 1, and top the value
  80.                               of the window’s height -15.
  81.  
  82.               (right,bottom)  To place the right side of the scroll bar
  83.                               exactly at the left edge of the “size
  84.                               box,” give right the value of the window’s
  85.                               width - 14, and bottom the value of the
  86.                               window’s height + 1.  If these exact
  87.                               dimensions are not used, the scroll bar
  88.                               will not be sized or moved when the
  89.                               window’s size is changed.
  90.  
  91.   EnabledFlag specifies if the scroll bar is enabled or disabled when the window is active.  When a scroll bar is disabled, the thumb and toned “page up” and “page down” regions disappear, and the scroll bar cannot be used by the operator.  The two constants that can be used for this purpose are enabled and disabled .  All scroll bars automatically become hidden (only the outline is shown) when the window containing them becomes inactive.  When the window is activated, the scroll bars will assume their normal state as set by the NewScrollBar procedure, and subsequent calls to the EnableScrollBar procedure.
  92.  
  93. Minimum declares the scroll bar’s minimum setting limit.
  94.  
  95.   Value defines the scroll bar’s current value.  The current value must be greater than or equal to the minimum setting, and less than or equal to the maximum setting.
  96.  
  97.   Maximum declares the scroll bar’s maximum setting limit.  The maximum setting limit must be greater than the minimum setting limit.
  98.  
  99. Also see:  NewScrollBarRect.
  100.  
  101. Note: Tools Plus makes no attempt to control the placement of scroll
  102.       bars or to protect them once they have been created.  It is the
  103.       programmer’s responsibility to ensure that scroll bars are of
  104.       sufficient length to contain the up/down arrows and the thumb, and
  105.       that their placement within the window is reasonable and does not
  106.       conflict with other objects.  Furthermore, you should not allow
  107.       your application’s text and drawing processes to interfere with
  108.       scroll bars.  Windows with a “size box” should not allow scroll
  109.       bars to be obscured or hidden by making the window too small.
  110.  
  111.   CONST                   {Scroll bar state                       }
  112.     enabled  =true;       {enable the scroll bar                  }
  113.     disabled =false;      {disable the scroll bar                 }
  114.  
  115. ------------------------------------------------------------------------
  116.  
  117. NewScrollBarRect
  118. ````````````````
  119. Create a new scroll bar.
  120.  
  121.    pascal void NewScrollBarRect (int ScrollBar, Rect *Bounds,
  122.                  Boolean EnabledFlag,
  123.                  int minimum, int value, int maximum);
  124.  
  125.    procedure NewScrollBarRect(ScrollBar: INTEGER; Bounds: RECT;
  126.                  EnabledFlag: BOOLEAN;
  127.                  minimum, value, maximum: INTEGER);
  128.  
  129.   NewScrollBarRect is identical to the NewScrollBar procedure, except that it accepts the Bounds rectangle in place of the individual left, top, right and bottom co-ordinates.
  130.  
  131. ------------------------------------------------------------------------
  132.  
  133. DeleteScrollBar
  134. ```````````````
  135. Delete a scroll bar.
  136.  
  137.    pascal void DeleteScrollBar (int ScrollBar);
  138.  
  139.    procedure DeleteScrollBar(ScrollBar: INTEGER);
  140.  
  141.   ScrollBar specifies the scroll bar number (from 1 to 255) that is deleted from the current window.  If the current window doesn’t belong to your application, or if no windows are open, or if the scroll bar does not exist in the current window, DeleteScrollBar does nothing.
  142.  
  143. ------------------------------------------------------------------------
  144.  
  145. EnableScrollBar
  146. ```````````````
  147. Enable or disable a scroll bar.
  148.  
  149.    pascal void EnableScrollBar (int ScrollBar, Boolean EnabledFlag);
  150.  
  151.    procedure EnableScrollBar(ScrollBar: INTEGER; EnabledFlag: BOOLEAN);
  152.  
  153.   ScrollBar specifies the scroll bar number (from 1 to 255) that is to be affected in the current window.  If the current window doesn’t belong to your application, or if no windows are open, or if the scroll bar does not exist in the current window, EnableScrollBar does nothing.
  154.  
  155.   EnabledFlag specifies if the scroll bar is enabled or disabled when the window is active.  When a scroll bar is disabled, the thumb and toned “page up” and “page down” regions disappear and the scroll bar cannot be selected by the user.  The two constants that can be used for this purpose are enabled and disabled .
  156.  
  157.   All scroll bars automatically become disabled if the window containing them becomes inactive.  When the window is activated, the scroll bars assume their normal state as set by the EnableScrollBar procedure.
  158.  
  159.   CONST                   {Scroll bar state                       }
  160.     enabled  =true;       {enable the scroll bar                  }
  161.     disabled =false;      {disable the scroll bar                 }
  162.  
  163. ------------------------------------------------------------------------
  164.  
  165. GetScrollBarMin
  166. ```````````````
  167. Get a scroll bar’s minimum setting limit.
  168.  
  169.    pascal int GetScrollBarMin (int ScrollBar);
  170.  
  171.    function GetScrollBarMin(ScrollBar: INTEGER): INTEGER;
  172.  
  173.   ScrollBar specifies the scroll bar number (from 1 to 255) that will be queried in the current window.
  174.  
  175.   GetScrollBarMin returns the value of a scroll bar’s minimum setting limit.  If the current window doesn’t belong to your application, or if no windows are open, or if the scroll bar does not exist in the current window, GetScrollBarMin will return a value of -maxInt.
  176.  
  177. ------------------------------------------------------------------------
  178.  
  179. SetScrollBarMin
  180. ```````````````
  181. Set a scroll bar’s minimum setting limit.
  182.  
  183.    pascal void SetScrollBarMin (int ScrollBar, int minimum);
  184.  
  185.    procedure SetScrollBarMin(ScrollBar, minimum: INTEGER);
  186.  
  187.   ScrollBar specifies the scroll bar number (from 1 to 255) that will be affected in the current window.  If the current window doesn’t belong to your application, or if no windows are open, or if the scroll bar does not exist in the current window, SetScrollBarMin does nothing.
  188.  
  189.   Minimum specifies the scroll bar’s new minimum setting limit.  The scroll bar’s current value and maximum setting are automatically adjusted (if necessary) to be consistent with the new minimum setting.
  190.  
  191. ------------------------------------------------------------------------
  192.  
  193. GetScrollBarMax
  194. ```````````````
  195. Get a scroll bar’s maximum setting limit.
  196.  
  197.    pascal int GetScrollBarMax (int ScrollBar);
  198.  
  199.    function GetScrollBarMax(ScrollBar: INTEGER): INTEGER;
  200.  
  201.   ScrollBar specifies the scroll bar number (from 1 to 255) that will be queried in the current window.
  202.  
  203.   GetScrollBarMax returns the value of a scroll bar’s maximum setting limit.  If the current window doesn’t belong to your application, or if no windows are open, or if the scroll bar does not exist in the current window, GetScrollBarMax will return a value of maxInt.
  204.  
  205. ------------------------------------------------------------------------
  206.  
  207. SetScrollBarMax
  208. ```````````````
  209. Set a scroll bar’s maximum setting limit.
  210.  
  211.    pascal void SetScrollBarMax (int ScrollBar, int maximum);
  212.  
  213.    procedure SetScrollBarMax(ScrollBar, maximum: INTEGER);
  214.  
  215.   ScrollBar specifies the scroll bar number (from 1 to 255) that will be affected in the current window.  If the current window doesn’t belong to your application, or if no windows are open, or if the scroll bar does not exist in the current window, SetScrollBarMax does nothing.
  216.  
  217.   Maximum specifies the scroll bar’s new maximum setting limit.  The scroll bar’s current value and minimum setting are automatically adjusted (if necessary) to be consistent with the new maximum setting.
  218.  
  219. ------------------------------------------------------------------------
  220.  
  221. GetScrollBarVal
  222. ```````````````
  223. Get a scroll bar’s current value.
  224.  
  225.    pascal int GetScrollBarVal (int ScrollBar);
  226.  
  227.    function GetScrollBarVal(ScrollBar: INTEGER): INTEGER;
  228.  
  229.   ScrollBar specifies the scroll bar number (from 1 to 255) that will be queried in the current window.
  230.  
  231.   GetScrollBarVal returns a scroll bar’s current value.  If the current window doesn’t belong to your application, or if no windows are open, or if the scroll bar does not exist in the current window, GetScrollBarVal will return a value of maxInt.
  232.  
  233. ------------------------------------------------------------------------
  234.  
  235. SetScrollBarVal
  236. ```````````````
  237. Set a scroll bar’s current value.
  238.  
  239.    pascal void SetScrollBarVal (int ScrollBar, int value);
  240.  
  241.    procedure SetScrollBarVal(ScrollBar, Value: INTEGER);
  242.  
  243.   ScrollBar specifies the scroll bar number (from 1 to 255) which is to be affected in the current window.  If the current window doesn’t belong to your application, or if no windows are open, or if the scroll bar does not exist in the current window, SetScrollBarVal does nothing.
  244.  
  245.   Value specifies the scroll bar’s new current value.  The scroll bar’s minimum and maximum settings are automatically adjusted (if necessary) to be consistent with the new current value.
  246.  
  247. ------------------------------------------------------------------------
  248.